<template>
 <div class>
      <el-card class="ep-card ep-search">
        <el-row :gutter="0">
          <el-col style="float:left"><span>当前位置:新增资信评分方案设置</span></el-col>
          <el-col :span="3" style="float:right">
            <el-button type="primary"  @click="back">返回</el-button>
          </el-col>
          <el-col :span="2" style="float:right">
            <el-button type="success"  @click="submit">保存</el-button>
          </el-col>
        </el-row>
      </el-card>
      <el-card>
      <div slot="header" style="color: blue;"><span>资信评分方案设置</span></div>
      <el-form :model="addForm" ref="addForm" label-width="140px" class="demo-addForm" size="mini">

        <el-row>
          <el-col :span="8">
            <my-form-item label="评分方案名称" prop="name">
              <el-input v-model="addForm.name"></el-input>
            </my-form-item>
          </el-col>
          <el-col :span="8">
            <my-form-item label="评分方案编码" prop="code">
              <el-input v-model="addForm.code"></el-input>
            </my-form-item>
          </el-col>
          <el-col :span="8">
            <my-form-item label="是否启用" prop="isEffect">
              <el-checkbox checked="true"></el-checkbox>
            </my-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <my-form-item label="定量比例(%)" prop="retionRate">
              <el-input v-model="addForm.retionRate"></el-input>
            </my-form-item>
          </el-col>
          <el-col :span="8">
            <my-form-item label="定性比例(%)" prop="determineNatureRate">
              <el-input v-model="addForm.determineNatureRate"></el-input>
            </my-form-item>
          </el-col>
          <el-col :span="8">
            <my-form-item label="启用日期" prop="effectDate">
              <el-date-picker type="date" placeholder="选择日期" v-model="addForm.effectDate" style="width: 80%;"></el-date-picker>
            </my-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <my-form-item label="备注" prop="remark">
              <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.remark" style="width: 80%;"></el-input>
            </my-form-item>
          </el-col>
        </el-row>
      </el-form>
      </el-card>

      <el-card>
        <div slot="header" style="color: blue;"><span>指标类型</span></div> 
        <el-table :data="tableData1" border style="width: 100%">
          <el-table-column  align="center" width="80">
            <template slot="header">
             <el-button class="el-icon-circle-plus" @click.prevent="addRow()"></el-button>
            </template>
            <template slot-scope="scope">
              <el-button size="mini" type="danger" class="el-icon-remove"
              @click="handleDelete(scope.$index, scope.row)"></el-button>
          </template>
          </el-table-column>
          
          <el-table-column label="指标类型编码" align="center" width="140">
            <template slot-scope="scope">
              <el-input v-model="scope.row.code"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="指标类型名称" align="center" width="140">
            <template slot-scope="scope">
              <el-input v-model="scope.row.name"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="所属分类" align="center" width="100">
            <template slot-scope="scope">
              <el-input v-model="scope.row.type"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="启用否" align="center" width="80">
            <template slot-scope="scope">
              <el-input v-model="scope.row.enable"></el-input>
            </template>
          </el-table-column>

          <el-table-column label="备注" align="center">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
 </div>
</template>
<script>
export default {
    data(){
        return {
          tableData1: [],
          ruleForm: {
            name: "",
            isEnable: ""
          },
          addForm: {
            name: "",
            isEnable: ""
          },
          currentPage4: 4,
          isEffectStatus: {"1":"是","0":"否"},
          addFormVisible: false
        }
      },
      mounted() {
        this.init();
      },
      methods: {
        dateFormatter: function (row, column) {
            let datetime = row[column.property];
            if(datetime){
                datetime = new Date(datetime);
                let y = datetime.getFullYear() + '-';
                let mon = datetime.getMonth()+1 + '-';
                let d = datetime.getDate();
                return y + mon + d;
            }
            return ''
        },
        formatData(val){
         return this.isEffectStatus[val.isEffect] 
        },
        // 增加行
        addRow() {
          var list = {
            code: this.code,
            name: this.name,
            type: this.type,
            enable: this.enable,
            remark: this.remark
          }
          this.tableData1.unshift(list)
        },
        handleDelete(index, row) {
            this.tableData1.splice(index, 1);
        },
        init(){
          this.$api.post(  "/api/biz/credit/goCreditSchemeAdd")
          .then(res => {
          console.log(res);
          if (res.retHead.code === "0000000") {
            console.log(res.retBody);
            this.tableData1 = res.retBody;
            this.total = res.retBody.total;
          }
        });
        },
        back(){
          this.$router.push({path:"/scheme/main"});
        },
        submit(){

        }

    }
}
</script>